-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make dialog and drawer more resilient to upcoming CloseWatcher API #1848
Merged
m-akinc
merged 5 commits into
main
from
users/makinc/dialog-handle-skipped-cancel-event
Feb 22, 2024
Merged
Make dialog and drawer more resilient to upcoming CloseWatcher API #1848
m-akinc
merged 5 commits into
main
from
users/makinc/dialog-handle-skipped-cancel-event
Feb 22, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 task
jattasNI
reviewed
Feb 21, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job providing rationale and comments for all the subtle behaviors in this PR!
Sorry, but last time adding @mollykreis as they are very close to the implementation and aware of the bug. Should be a quick double check. |
rajsite
approved these changes
Feb 21, 2024
rajsite
reviewed
Feb 21, 2024
rajsite
reviewed
Feb 21, 2024
mollykreis
approved these changes
Feb 21, 2024
jattasNI
approved these changes
Feb 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request
🤨 Rationale
There is a change to the HTML spec introducing the
CloseWatcher
API, which affects the way the nativedialog
element behaves. Recently, Chrome had released their implementation, and it broke our drawer and dialog (see issue #1713, as well as resulting Chromium issue). Though they rolled back their release of that feature (by moving it back to experimental), it will eventually be implemented in Chrome and other browsers in some form. We want to at least guard against leaving the drawer/dialog in a bad state.Also fixes #1445
👩💻 Implementation
The issue is that the
cancel
event is intentionally not fired in a couple cases where thedialog
is dismissed with ESC.dialog
before pressing ESC. Apparently, this is viewed as a mistake and will likely be changed.CloseWatcher
API is when there are two ESC presses without an intervening user interaction.I have added a
close
event handler in both the drawer and dialog that resolves and clears the promise, if there is one still set. This ensures we are not left in a bad state where the drawer/dialog can't be reopened. Note there are still problems:cancel
event to trigger the animation)prevent-dismiss
is setDepending on the ultimate
CloseWatcher
specification, we may decide to deprecate theprevent-dismiss
option.OTHER CHANGES:
🧪 Testing
I added tests for the specific case now being handled, though these won't currently be running against any browser versions that would exhibit the problem behavior.
I did manual testing using a version of Chromium with the
CloseWatcher
API enabled.✅ Checklist